package game.util.sosc;

import java.awt.Dimension;

public class DimensionConverter implements IStringObjectStringConverter<Dimension>
{
    @Override
    public Dimension toObject(String string)
    {
        String width  = string.substring("width=".length(), string.indexOf(",height="));
        String height = string.substring(string.lastIndexOf("=") + 1);
        return new Dimension(Integer.parseInt(width), Integer.parseInt(height));
    }

    @Override
    public String toString(Dimension object)
    {
        StringBuilder string = new StringBuilder();
        string.append("width=").append(object.width);
        string.append(",height=").append(object.height);
        return string.toString();
    }
}
